<?php
namespace App\Repositories\Api;

use App\Models\Feedback;
use App\Repositories\FileRepository;

use Exception;

class FeedbackRepository
{

    public function saveFeedback(int $id, int $adminId, string $content )
    {
        $feedback = Feedback::where(['id' => $id])->first();
        if(!$feedback){
            throw new Exception("数据错误，请重试", 1);
        }
        $res = Feedback::where("id", "=", $id)->update(['content' => $content, "status" => 1]);
        return $res;
    }

    // 创建空
    public function createFeedback($adminId)
    {
        $res = Feedback::where(['admin_id' => $adminId, 'status' => 2])->first();
        if(!$res){
            $res = Feedback::Create([
                'admin_id'      => $adminId,
                'status'        => 2
            ]);
        }

        return $res;
    }
}

